from sqlalchemy.orm import DeclarativeBase, Mapped, mapped_column, relationship
from sqlalchemy import Integer, String
from ..database.db import Base
from sqlalchemy import Column, Integer, String, DateTime, SmallInteger, PrimaryKeyConstraint
from datetime import datetime

class Sources(Base):
    __tablename__ = 'sources'
    # 定义 id 列，类型为 Integer，为主键且不为空
    id: Mapped[int] = mapped_column(Integer, primary_key=True, nullable=False,autoincrement=True)

    # 定义 name 列，类型为 String(255)，且不为空
    name: Mapped[str] = mapped_column(String(255), nullable=False)

    # textbooks = relationship("Textbook", back_populates="source")
    # papers = relationship("Paper", back_populates="source")
    def as_dict(self):
        return {c.name: getattr(self, c.name) for c in self.__table__.columns}